home *** CD-ROM | disk | FTP | other *** search
/ Champak 43 / Vol 43.iso / games / phit.swf / scripts / __Packages / CPhitGameCodeCreate.as < prev    next >
Encoding:
Text File  |  2007-07-13  |  3.5 KB  |  96 lines

  1. class CPhitGameCodeCreate extends CPhitGame
  2. {
  3.    var _arrHostsAwaitingNextOnEnterFrame;
  4.    var _arrFieldHosts;
  5.    var _createStartWaitUpdate = 10000000;
  6.    var _iRetainedStartLevel = undefined;
  7.    function CPhitGameCodeCreate()
  8.    {
  9.       super();
  10.    }
  11.    function FirstFrameInitialize()
  12.    {
  13.       this._arrHostsAwaitingNextOnEnterFrame = new Array();
  14.       this._iRetainedStartLevel = _root._iStartLevel;
  15.       super.FirstFrameInitialize();
  16.    }
  17.    function FinishFieldSequence()
  18.    {
  19.       FreshDebug.Trace("CPhitGameCodeCreate.FinishFieldSequence() _iLevel=" + this._iLevel + ", _iRetainedStartLevel=" + this._iRetainedStartLevel);
  20.       if(this._iRetainedStartLevel != undefined)
  21.       {
  22.          this._iLevel = this._iRetainedStartLevel;
  23.          this._iRetainedStartLevel = undefined;
  24.       }
  25.       FreshDebug.Assert(this._iLevel < this._arrFieldHosts.length,"_iLevel < _arrFieldHosts.length");
  26.       FreshDebug.Trace("using fieldhost " + this._iLevel);
  27.       this._fieldHost = this._arrFieldHosts[this._iLevel];
  28.       this._field = this._fieldHost._field;
  29.       this._fieldHost.PlayAppear();
  30.    }
  31.    function onEnterFrame()
  32.    {
  33.       if(this.m_nUpdates > this._createStartWaitUpdate + 2 && this._arrHostsAwaitingNextOnEnterFrame.length > 0)
  34.       {
  35.          var _loc4_ = 0;
  36.          while(_loc4_ < this._arrHostsAwaitingNextOnEnterFrame.length)
  37.          {
  38.             var _loc3_ = this._arrHostsAwaitingNextOnEnterFrame[_loc4_];
  39.             _loc3_.resume(_loc3_.host,_loc3_.width,_loc3_.height);
  40.             this.ScaleField(_loc3_.host);
  41.             _loc4_ = _loc4_ + 1;
  42.          }
  43.          this._arrHostsAwaitingNextOnEnterFrame.splice(0);
  44.          this.FinishFieldSequence();
  45.       }
  46.       super.onEnterFrame();
  47.    }
  48.    function StartNextLevel()
  49.    {
  50.       this._iLevel = this._iLevel + 1;
  51.       FreshDebug.Trace("moving to level " + this._iLevel);
  52.       _root._presentation.StoreLastPlayedLevel(this._iLevel);
  53.       if(this._arrFieldHosts[this._iLevel] != undefined)
  54.       {
  55.          FreshDebug.Trace("Using prebuilt level.");
  56.          this._fieldHost = this._arrFieldHosts[this._iLevel];
  57.          this._field = this._fieldHost._field;
  58.          this._isFieldSolved = false;
  59.          this._doneShuffling = true;
  60.          this._fieldHost.PlayAppear();
  61.       }
  62.       else
  63.       {
  64.          this.StartFieldSequence();
  65.       }
  66.    }
  67.    function CreatePlayingField(iLevel, width, height, resumeFn)
  68.    {
  69.       var _loc3_ = iLevel;
  70.       this.attachMovie("Field Host","fieldHost" + _loc3_,_loc3_);
  71.       var _loc2_ = CFieldHost(this["fieldHost" + _loc3_]);
  72.       this._arrFieldHosts[iLevel] = _loc2_;
  73.       this._arrHostsAwaitingNextOnEnterFrame.push({host:_loc2_,resume:resumeFn,width:width,height:height});
  74.       FreshDebug.Assert(_loc2_ != undefined,"_fieldHost != undefined");
  75.       FreshDebug.Assert(_loc2_._field != undefined,"_fieldHost._field != undefined");
  76.       this._doneShuffling = true;
  77.       this._isFieldSolved = false;
  78.       return _loc2_._field;
  79.    }
  80.    function StartFieldSequence()
  81.    {
  82.       var _loc4_ = "StartCreatingLevel" + this._iLevel;
  83.       if(_root[_loc4_] != undefined && _root[_loc4_] instanceof Function)
  84.       {
  85.          FreshDebug.Trace("Using creation function " + _loc4_);
  86.          this._createStartWaitUpdate = this.m_nUpdates;
  87.          _root[_loc4_]();
  88.       }
  89.       else
  90.       {
  91.          FreshDebug.Trace("Found no creation function " + _loc4_);
  92.          super.StartFieldSequence();
  93.       }
  94.    }
  95. }
  96.